package week02

// 153. 寻找旋转排序数组中的最小值
// https://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array/

func findMin(nums []int) int {
	var min = nums[len(nums) - 1]
	var left, right = 0, len(nums)
	for left < right {
		var mid = (right - left) >> 1 + left
		if nums[mid] <= min {
			right = mid
			min = nums[mid]
		} else {
			left = mid + 1
		}
	}
	return nums[right]
}